package com.reggie.service.impl;

import com.reggie.service.ShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ShopServiceImpl implements ShopService {

    private static final String KEY = "SHOP:STATUS";

    //注入Redis配置类
    @Autowired
    private RedisTemplate redisTemplate;

   //修改营业状态
    public void setShopStatus(Integer status) {
        redisTemplate.opsForValue().set(KEY,status);
        log.info("设置店铺的营业状态为:{}",status==1?"营业":"打烊");

    }

    //获取营业状态
    public Integer getStatus() {
        return (Integer) redisTemplate.opsForValue().get(KEY);
    }
}
